﻿using System;
using System.Globalization;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using RTMBindings.Responses;

namespace RTMBindings
{
    public class RTMTaskBindings : RTMBindings
    {
        private const string GetListUrl = UriBase + "rtm.tasks.getList&api_key={0}&auth_token={1}";
        private const string PostponeTaskUrl = UriBase + "rtm.tasks.getList&api_key={0}&auth_token={1}&timeline={2}&list_id={3}&taskseries_id={4}&task_id={5}";

        private RTMTaskBindings() { }

        public static void GetList(string apiKey, string secret, RTMToken token, Action<RTMGetListResponse> callback, Action<Exception> failedCallback, int? listId = null, string filter = null, DateTime? lastSync = null)
        {
            var uri = string.Format(GetListUrl, apiKey, token.Token);
            if (listId != null)
                uri += string.Format("&list_id={0}", listId);
            if (!string.IsNullOrWhiteSpace(filter))
                uri += string.Format("&filter={0}", filter);
            if (lastSync != null)
                uri += string.Format("&last_sync={0}", lastSync.Value.ToString("s", CultureInfo.InvariantCulture));

            RequestString(secret, new UriBuilder(uri), callback, failedCallback);
        }
    }
}
